﻿
<?php
// print_r($_POST);EXIT;


    if(!empty($_POST)){

         //把表单的值存放到这四个变量中
        $name=$_POST['name'];

        $password=$_POST['password'];

        $user_address=$_POST['user_address'];

        $cellphone=$_POST['cellphone'];

         $sex=$_POST['sex'];

        $age=$_POST['age'];

         //链接数据库



        // print_r($_POST);

       $sql = "INSERT INTO `admin`(`name`,`password`,`user_address`,`cellphone`,`sex`,`age`) VALUES ('$name','$password','$user_address','$cellphone','$sex','$age')";

           mysqli_query($link,'set names utf8');

        mysqli_query($link,$sql);

       $xf=mysqli_affected_rows($link);


        // print_r($xf);
               //判断$xf的值是否大于0，大于则编辑成功
           if($xf>0){

               echo '<script>alert("添加成功");location.href="index.php?c=admin&&a=list&&admin=1"; </script>';

            }else{

        echo '<script>alert("添加失败");history.go(-1) </script>';
      }
}

 //载入后台公共视图
    include_once (VIEW_PATH.'admin/layout.html');

?>